|
RAIS
3.2
|
00001 00028 using System; 00029 using System.Data; 00030 using System.Configuration; 00031 using System.Collections; 00032 using System.Collections.Generic; 00033 using System.Web; 00034 using System.Web.Security; 00035 using System.Web.UI; 00036 using System.Web.UI.WebControls; 00037 using System.Web.UI.WebControls.WebParts; 00038 using System.Web.UI.HtmlControls; 00039 00040 using RAIS.Common.UserManagement; 00041 00042 using DataRoles = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.DataRole>; 00043 using DataRoleAttributes = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.DataRoleAttribute>; 00044 using FunctionRoles = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole>; 00045 using FunctionRoleCategories = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole.Category>; 00046 using FunctionRoleSubcategories = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole.Subcategory>; 00047 using Masks = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.Mask>; 00048 using FunctionRoleAttributes = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRoleAttribute>; 00049 using UserTypes = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.UserTypeData>; 00050 00051 namespace RAIS.UI.SpecificMasks 00052 { 00056 public partial class EditFunctionalRoles : System.Web.UI.Page 00057 { 00058 #region Event handlers 00059 protected void Page_PreLoad(object sender, EventArgs e) 00060 { 00061 RAIS.UI.Common.PageManagement.TrimTextBoxValues(this); 00062 } 00073 protected void Page_Load(object sender, EventArgs e) 00074 { 00075 this.Response.Redirect("EditFunctionalRoles_New.aspx"); 00076 00077 if (this.CurrentUser == null) 00078 UI.Common.AccessManagement.SignOut(this); 00079 00080 if (!this.IsPostBack) 00081 { 00082 this.BTNfmdelete.Attributes.Add("onclick", string.Format("javascript: return confirm('{0}');", RAIS.Common.Messages.DELETE_QUESTION_FUNCTIONAL_ROLE.Replace("'", "\\'"))); 00083 UI.Common.UserManagement.InitializeFunctionalRoles(this); 00084 } 00085 00086 this.InitializeControls(); 00087 this.EnableRemoveButton(); 00088 00089 this.LBLresult.Text = ""; 00090 00091 if (!this.IsPostBack) 00092 { 00093 this.LBLusername.Text = this.CurrentUser.Name; 00094 this.EditMode = false; 00095 00096 UI.Common.PageManagement.InitializePage(this, this.TreeView1); 00097 // this.LBTNmessagebox.Visible = !(this.CurrentUser.FunctionalRole.Type == FunctionRole.FunctionRoleType.Guest); 00098 } 00099 } 00100 protected void Page_Init(object sender, EventArgs e) 00101 { 00102 Common.PageManagement.SetScrolableListBox(LBfm, this, true); 00103 } 00110 protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) 00111 { 00112 UI.Common.UserManagement.ProcessTreeViewOnRedirect(this.TreeView1); 00113 } 00120 protected void Page_Unload(object sender, EventArgs e) 00121 { 00122 // save the state of all nodes. 00123 //UI.Common.UserManagement.InitializeSiteMapTree(this.TreeView1); 00124 } 00131 protected void LBTNlogout_Click(object sender, EventArgs e) 00132 { 00133 UI.Common.AccessManagement.SignOut(this); 00134 } 00145 protected void DDLfmrolename_SelectedIndexChanged(object sender, EventArgs e) 00146 { 00147 // UI.Common.UserManagement.InitializeFuncitonRoleAttributesList(this.LBfm, this.SelectedRole, this.a); 00148 this.InitializaValidationSelection(this.SelectedRole); 00149 this.InitializeUserTypesCheckBoxes(this.SelectedRole); 00150 this.InitializeAccessFlags(this.SelectedRoleAttribute); 00151 } 00159 protected void BTNfmdelete_Click(object sender, EventArgs e) 00160 { 00161 if (this.ConfirmRoleDeletion()) 00162 { 00163 this.DeleteSelectedRole(); 00164 } 00165 } 00173 protected void BTNedit_Click(object sender, EventArgs e) 00174 { 00175 this.EditMode = true; 00176 this.EnableRemoveButton(); 00177 } 00185 protected void BTNsave_Click(object sender, EventArgs e) 00186 { 00187 this.SaveRole(); 00188 this.EnableRemoveButton(); 00189 this.InitializeAccessFlags(this.SelectedRoleAttribute); 00190 this.InitializaValidationSelection(this.SelectedRole); 00191 } 00199 protected void BTNdiscard_Click(object sender, EventArgs e) 00200 { 00201 this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG] = null; //for resetting 00202 this.InitializeControls(); 00203 this.EnableRemoveButton(); 00204 this.EditMode = false; 00205 } 00213 protected void BTNfmnewrole_Click(object sender, EventArgs e) 00214 { 00215 this.AddNewRole(); 00216 this.EnableRemoveButton(); 00217 this.InitializeAccessFlags(this.SelectedRoleAttribute); 00218 this.InitializaValidationSelection(this.SelectedRole); 00219 } 00227 protected void RBvalidationNeeds_CheckedChanged(object sender, EventArgs e) 00228 { 00229 if( this.RBvalidationNeeds.Checked ) 00230 this.SetNewValidationSelection(FunctionRole.ValidationType.NeedsValidation); 00231 } 00239 protected void RBvalidationValidates_CheckedChanged(object sender, EventArgs e) 00240 { 00241 if (this.RBvalidationValidates.Checked) 00242 this.SetNewValidationSelection(FunctionRole.ValidationType.Validates); 00243 } 00251 protected void RBvalidationNoNeed_CheckedChanged(object sender, EventArgs e) 00252 { 00253 if (this.RBvalidationNoNeed.Checked) 00254 this.SetNewValidationSelection(FunctionRole.ValidationType.DoesNotNeedValidation); 00255 } 00264 protected void DDLfmcategories_SelectedIndexChanged(object sender, EventArgs e) 00265 { 00266 UI.Common.UserManagement.InitializeSubcategoriesList( this.DDLfmsubcategories, 00267 this.SelectedCategory, 00268 this.SelectedRole); 00269 00270 UI.Common.UserManagement.InitializeMasksList(this.DDLfmmask, 00271 this.SelectedCategory, 00272 this.SelectedSubcategory, 00273 this.SelectedRole); 00274 } 00282 protected void DDLfmsubcategories_SelectedIndexChanged(object sender, EventArgs e) 00283 { 00284 UI.Common.UserManagement.InitializeMasksList(this.DDLfmmask, 00285 this.SelectedCategory, 00286 this.SelectedSubcategory, 00287 this.SelectedRole); 00288 } 00296 protected void BTNfmadd_Click(object sender, EventArgs e) 00297 { 00298 this.AddFunctionRoleAttribute(); 00299 this.InitializeControls(); 00300 this.EnableRemoveButton(); 00301 this.InitializeAccessFlags(this.SelectedRoleAttribute); 00302 } 00310 protected void BTNfmremove_Click(object sender, EventArgs e) 00311 { 00312 this.RemoveFunctionRoleAttribute(); 00313 this.InitializeControls(); 00314 this.EnableRemoveButton(); 00315 this.InitializeAccessFlags(this.SelectedRoleAttribute); 00316 } 00322 protected void LBfm_SelectedIndexChanged(object sender, EventArgs e) 00323 { 00324 this.InitializeAccessFlags(this.SelectedRoleAttribute); 00325 UI.Common.UserManagement.InitializeCategoriesList(this.DDLfmcategories, this.SelectedRole); 00326 00327 UI.Common.UserManagement.InitializeSubcategoriesList(this.DDLfmsubcategories, 00328 this.SelectedRoleAttribute.Category, 00329 this.SelectedRole); 00330 00331 UI.Common.UserManagement.InitializeMasksList(this.DDLfmmask, 00332 this.SelectedRoleAttribute.Category, 00333 this.SelectedRoleAttribute.Subcategory, 00334 this.SelectedRole); 00335 try 00336 { 00337 this.SetCategorySelection(this.SelectedRoleAttribute); 00338 this.SetSubcategorySelection(this.SelectedRoleAttribute); 00339 this.SetMaskSelection(this.SelectedRoleAttribute); 00340 } 00341 catch 00342 { 00343 00344 } 00345 this.EnableRemoveButton(); 00346 } 00347 00348 protected void UserTypeCheckBox_CheckedChanged(object sender, EventArgs e) 00349 { 00350 CheckBox checkBox = (CheckBox)sender; 00351 UserTypeCheckBoxCheckedChanged(checkBox); 00352 this.InitializeUserTypesCheckBoxes(this.SelectedRole); 00353 } 00354 #endregion 00355 #region Private helper methods 00356 00362 private void SetCategorySelection(FunctionRoleAttribute roleAttribute) 00363 { 00364 if (roleAttribute != null) 00365 { 00366 this.DDLfmcategories.SelectedValue = roleAttribute.Category.Name; 00367 } 00368 } 00374 private void SetSubcategorySelection(FunctionRoleAttribute roleAttribute) 00375 { 00376 if (roleAttribute != null) 00377 { 00378 this.DDLfmsubcategories.SelectedValue = roleAttribute.Subcategory.Name; 00379 } 00380 } 00386 private void SetMaskSelection(FunctionRoleAttribute roleAttribute) 00387 { 00388 if (roleAttribute != null) 00389 { 00390 this.DDLfmmask.SelectedValue = roleAttribute.Mask.Name; 00391 } 00392 } 00396 private void DeleteSelectedRole() 00397 { 00398 FunctionRole selectedRole = this.SelectedRole; 00399 00400 if (selectedRole != null) 00401 { 00402 string returnMessage = ""; 00403 bool success = ApplicationLogicLayer.UserManagement.RemoveFunctionRole(selectedRole, ref returnMessage); 00404 this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG] = null; //for resetting 00405 UI.Common.UserManagement.InitializeFunctionalRolesList(this.DDLfmrolename); 00406 //UI.Common.UserManagement.InitializeFuncitonRoleAttributesList(this.LBfm, this.SelectedRole); 00407 this.EnableRemoveButton(); 00408 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage( this.LBLresult, 00409 returnMessage, 00410 success); 00411 } 00412 } 00417 private bool ConfirmRoleDeletion() 00418 { 00419 return true; 00420 } 00425 private bool SaveRole() 00426 { 00427 string returnMessage = ""; 00428 bool success = true; 00429 00430 if (!this.Modified) 00431 { 00432 returnMessage = RAIS.Common.Messages.FUNCTION_ROLE_NO_MODIFICATION; 00433 success = false; 00434 } 00435 else 00436 { 00437 success = ApplicationLogicLayer.UserManagement.SaveFunctionRole(this.SelectedRole, ref returnMessage); 00438 if (success) 00439 this.EditMode = false; 00440 } 00441 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult, 00442 returnMessage, 00443 success); 00444 return success; 00445 } 00450 private bool AddNewRole() 00451 { 00452 string validationMessage = ""; 00453 bool success = this.ValidateNewFuncitonalRole(this.TXTnewrole.Text, ref validationMessage); 00454 00455 if (this.TXTnewrole.Text.Length == 0) 00456 { 00457 validationMessage = RAIS.Common.Messages.FUNCTION_ROLE_NAME_MISSING; 00458 success = false; 00459 } 00460 00461 if (success) 00462 { 00463 success = ApplicationLogicLayer.UserManagement.AddFunctionRole(this.TXTnewrole.Text, ref validationMessage); 00464 if (success) 00465 { 00466 this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG] = null; //for resetting 00467 UI.Common.UserManagement.InitializeFunctionalRolesList(this.DDLfmrolename); 00468 this.DDLfmrolename.SelectedValue = this.TXTnewrole.Text; 00469 this.TXTnewrole.Text = ""; 00470 this.InitializeControls(); 00471 //UI.Common.UserManagement.InitializeFuncitonRoleAttributesList(this.LBfm, this.SelectedRole); 00472 } 00473 } 00474 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage( this.LBLresult, 00475 validationMessage, 00476 success); 00477 return success; 00478 } 00487 bool ValidateNewFuncitonalRole(string roleName, ref string returnMessage) 00488 { 00489 FunctionRoles funcitonRoles = (FunctionRoles)this.Session[UI.Common.Constants.FUNCTION_ROLES_TAG]; 00490 if (funcitonRoles.ContainsKey(roleName)) 00491 { 00492 returnMessage = RAIS.Common.Messages.FUNCTION_ROLE_EXISTS; 00493 return false; 00494 } 00495 else 00496 if (roleName.Length == 0) 00497 { 00498 returnMessage = RAIS.Common.Messages.NAME_IS_EMTPY; 00499 return false; 00500 } 00501 else 00502 return true; 00503 } 00509 private bool SetNewValidationSelection(FunctionRole.ValidationType newSelection) 00510 { 00511 FunctionRole selectedRole = this.SelectedRole; 00512 if (selectedRole != null) 00513 { 00514 selectedRole.Validation = newSelection; 00515 this.EnableDisableControls(); 00516 00517 string returnMessage = RAIS.Common.Messages.MODIFICATION_PRESS_SAVE; 00518 00519 // bool success = ApplicationLogicLayer.UserManagement.SaveFunctionRole(selectedRole, ref returnMessage); 00520 00521 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage( this.LBLresult, 00522 returnMessage, 00523 true); 00524 00525 } 00526 return false; 00527 } 00531 private void AddFunctionRoleAttribute() 00532 { 00533 FunctionRole selectedRole = this.SelectedRole; 00534 if (selectedRole != null) 00535 { 00536 FunctionRoleAttribute functionAttribute = new FunctionRoleAttribute(); 00537 functionAttribute.Category = this.SelectedCategory; 00538 functionAttribute.Subcategory = this.SelectedSubcategory; 00539 functionAttribute.Mask = this.SelectedMask; 00540 00541 functionAttribute.AccessView = this.CBfmview.Checked; 00542 functionAttribute.AccessAdd = this.CBfmadd.Checked; 00543 functionAttribute.AccessEdit = this.CBfmedit.Checked; 00544 functionAttribute.AccessDelete = this.CBfmdelete.Checked; 00545 00546 string returnMessage = RAIS.Common.Messages.MODIFICATION_PRESS_SAVE; 00547 00548 bool success = this.ValidateNewFunctionRoleAttribute(functionAttribute, ref returnMessage); 00549 if (success) 00550 { 00551 success = selectedRole.AddAttribute(functionAttribute, ref returnMessage); 00552 this.EnableDisableControls(); 00553 00554 //UI.Common.UserManagement.InitializeFuncitonRoleAttributesList(this.LBfm, this.SelectedRole); 00555 this.LBfm.SelectedValue = functionAttribute.ToString(); 00556 00557 } 00558 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult, 00559 returnMessage, 00560 success); 00561 } 00562 } 00566 private void RemoveFunctionRoleAttribute() 00567 { 00568 FunctionRole selectedRole = this.SelectedRole; 00569 if (selectedRole != null) 00570 { 00571 FunctionRoleAttribute attribute = this.SelectedRoleAttribute; 00572 00573 string returnMessage = RAIS.Common.Messages.MODIFICATION_PRESS_SAVE; 00574 00575 bool success = selectedRole.RemoveAttribute(attribute, ref returnMessage); 00576 00577 this.EnableDisableControls(); 00578 00579 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult, 00580 returnMessage, 00581 success); 00582 } 00583 } 00592 bool ValidateNewFunctionRoleAttribute(FunctionRoleAttribute newFuncitonRoleAttribute, ref string returnMessage) 00593 { 00594 FunctionRole funcitonRole = this.SelectedRole; 00595 if (funcitonRole == null) 00596 { 00597 returnMessage = RAIS.Common.Messages.FUNCTION_ROLE_DOES_NOT_EXIST; 00598 return false; 00599 } 00600 else 00601 { 00602 return funcitonRole.ValidateNewAttribute(newFuncitonRoleAttribute, ref returnMessage); 00603 } 00604 } 00608 private void EnableRemoveButton() 00609 { 00610 this.BTNfmremove.Enabled = this.LBfm.Items.Count > 0 && 00611 this.SelectedRole.Attributes.ContainsKey(this.LBfm.SelectedValue) && 00612 this.EditMode; 00613 } 00617 private void InitializeAccessFlags(FunctionRoleAttribute attribute) 00618 { 00619 if( attribute != null ) 00620 { 00621 this.CBfmadd.Checked = attribute.AccessAdd; 00622 this.CBfmdelete.Checked = attribute.AccessDelete; 00623 this.CBfmedit.Checked = attribute.AccessEdit; 00624 this.CBfmview.Checked = attribute.AccessView; 00625 } 00626 else 00627 { 00628 this.CBfmadd.Checked = false; 00629 this.CBfmdelete.Checked = false; 00630 this.CBfmedit.Checked = false; 00631 this.CBfmview.Checked = false; 00632 } 00633 } 00637 private void InitializaValidationSelection(FunctionRole functionalRole) 00638 { 00639 if (functionalRole != null) 00640 { 00641 switch (functionalRole.Validation) 00642 { 00643 case FunctionRole.ValidationType.NeedsValidation: 00644 this.RBvalidationNeeds.Checked = true; 00645 this.RBvalidationValidates.Checked = false; 00646 this.RBvalidationNoNeed.Checked = false; 00647 break; 00648 case FunctionRole.ValidationType.Validates: 00649 this.RBvalidationNeeds.Checked = false; 00650 this.RBvalidationValidates.Checked = true; 00651 this.RBvalidationNoNeed.Checked = false; 00652 break; 00653 case FunctionRole.ValidationType.DoesNotNeedValidation: 00654 this.RBvalidationNeeds.Checked = false; 00655 this.RBvalidationValidates.Checked = false; 00656 this.RBvalidationNoNeed.Checked = true; 00657 break; 00658 } 00659 } 00660 } 00664 private void InitializeUserTypesCheckBoxes(FunctionRole functionalRole) 00665 { 00666 UserTypes userTypes = UI.Common.UserManagement.UserTypes; 00667 foreach (KeyValuePair<string, UserTypeData> kvp in userTypes) 00668 { 00669 UserTypeData userType = kvp.Value; 00670 //switch (userType.Type) 00671 //{ 00672 // case UserData.UserType.Admin: 00673 // this.CBadmin.Text = userType.VisibleName; 00674 // break; 00675 // case UserData.UserType.Guest: 00676 // this.CBguest.Text = userType.VisibleName; 00677 // break; 00678 // case UserData.UserType.Licensee: 00679 // this.CBlicensee.Text = userType.VisibleName; 00680 // break; 00681 // case UserData.UserType.PublicBody: 00682 // this.CBpublicbody.Text = userType.VisibleName; 00683 // break; 00684 // case UserData.UserType.Regulator: 00685 // this.CBregulator.Text = userType.VisibleName; 00686 // break; 00687 //} 00688 } 00689 00690 this.CBadmin.Checked = false; 00691 this.CBguest.Checked = false; 00692 this.CBlicensee.Checked = false; 00693 this.CBpublicbody.Checked = false; 00694 this.CBregulator.Checked = false; 00695 00696 if (functionalRole != null && functionalRole.UserTypes != null) 00697 { 00698 foreach (KeyValuePair<string, UserTypeData> kvp in functionalRole.UserTypes) 00699 { 00700 UserTypeData userType = kvp.Value; 00701 //switch (userType.Type) 00702 //{ 00703 // case UserData.UserType.Admin: 00704 // this.CBadmin.Checked = true; 00705 // break; 00706 // case UserData.UserType.Guest: 00707 // this.CBguest.Checked = true; 00708 // break; 00709 // case UserData.UserType.Licensee: 00710 // this.CBlicensee.Checked = true; 00711 // break; 00712 // case UserData.UserType.PublicBody: 00713 // this.CBpublicbody.Checked = true; 00714 // break; 00715 // case UserData.UserType.Regulator: 00716 // this.CBregulator.Checked = true; 00717 // break; 00718 //} 00719 } 00720 } 00721 } 00725 private void InitializeControls() 00726 { 00727 UI.Common.UserManagement.InitializeFunctionalRolesList(this.DDLfmrolename); 00728 UI.Common.UserManagement.InitializeCategoriesList(this.DDLfmcategories, this.SelectedRole); 00729 00730 UI.Common.UserManagement.InitializeSubcategoriesList(this.DDLfmsubcategories, 00731 this.SelectedCategory, 00732 this.SelectedRole); 00733 00734 UI.Common.UserManagement.InitializeMasksList(this.DDLfmmask, 00735 this.SelectedCategory, 00736 this.SelectedSubcategory, 00737 this.SelectedRole); 00738 00739 //UI.Common.UserManagement.InitializeFuncitonRoleAttributesList(this.LBfm, this.SelectedRole); 00740 00741 if (!this.RBvalidationNeeds.Checked && 00742 !this.RBvalidationValidates.Checked && 00743 !this.RBvalidationNoNeed.Checked) 00744 { 00745 this.InitializaValidationSelection(this.SelectedRole); 00746 } 00747 this.InitializeUserTypesCheckBoxes(this.SelectedRole); 00748 } 00752 private void EnableDisableControls() 00753 { 00754 this.LBfm.Enabled = this.EditMode; 00755 this.CBfmview.Enabled = this.EditMode; 00756 this.CBfmedit.Enabled = this.EditMode; 00757 this.CBfmadd.Enabled = this.EditMode; 00758 this.CBfmdelete.Enabled = this.EditMode; 00759 00760 this.CBadmin.Enabled = this.EditMode; 00761 this.CBguest.Enabled = this.EditMode; 00762 this.CBlicensee.Enabled = this.EditMode; 00763 this.CBpublicbody.Enabled = this.EditMode; 00764 this.CBregulator.Enabled = this.EditMode; 00765 00766 this.DDLfmcategories.Enabled = this.EditMode; 00767 this.DDLfmsubcategories.Enabled = this.EditMode; 00768 this.DDLfmmask.Enabled = this.EditMode; 00769 00770 this.RBvalidationValidates.Enabled = this.EditMode; 00771 this.RBvalidationNoNeed.Enabled = this.EditMode; 00772 this.RBvalidationNeeds.Enabled = this.EditMode; 00773 00774 this.BTNfmadd.Enabled = this.EditMode; 00775 this.BTNfmremove.Enabled = this.EditMode; 00776 00777 this.BTNedit.Enabled = !this.EditMode; 00778 this.BTNsave.Enabled = this.Modified; 00779 this.BTNdiscard.Enabled = this.EditMode; 00780 00781 this.DDLfmrolename.Enabled = !this.EditMode; 00782 this.TXTnewrole.Enabled = !this.EditMode; 00783 this.BTNfmdelete.Enabled = !this.EditMode; 00784 this.BTNfmnewrole.Enabled = !this.EditMode; 00785 00786 UI.Common.UserManagement.EnableCommonControls(this, !this.EditMode); 00787 this.LBLadmin.ForeColor = RAIS.UI.Common.Constants.COLOR_OF_MENU_BAR_TEXT_HIGHLIGHT; 00788 } 00789 00790 private void UserTypeCheckBoxCheckedChanged(CheckBox checkBox) 00791 { 00792 if (checkBox.Checked) 00793 RemoveUserTypeFromFunctionalRole(checkBox.Text); 00794 else 00795 AddUserTypeToFunctionalRole(checkBox.Text); 00796 } 00797 00798 private void AddUserTypeToFunctionalRole(string checkedType) 00799 { 00800 FunctionRole selectedRole = this.SelectedRole; 00801 if (selectedRole != null) 00802 { 00803 UserTypes userTypes = UI.Common.UserManagement.UserTypes; 00804 if (userTypes.ContainsKey(checkedType)) 00805 { 00806 UserTypeData userType = userTypes[checkedType]; 00807 00808 string returnMessage = RAIS.Common.Messages.MODIFICATION_PRESS_SAVE; 00809 00810 bool success = selectedRole.AddUserType(userType, ref returnMessage); 00811 00812 this.EnableDisableControls(); 00813 00814 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult, 00815 returnMessage, 00816 success); 00817 } 00818 } 00819 } 00820 00821 private void RemoveUserTypeFromFunctionalRole(string uncheckedType) 00822 { 00823 FunctionRole selectedRole = this.SelectedRole; 00824 if (selectedRole != null) 00825 { 00826 UserTypes userTypes = UI.Common.UserManagement.UserTypes; 00827 if (userTypes.ContainsKey(uncheckedType)) 00828 { 00829 UserTypeData userType = userTypes[uncheckedType]; 00830 00831 string returnMessage = RAIS.Common.Messages.MODIFICATION_PRESS_SAVE; 00832 00833 bool success = this.ValidateRemoveUserTypeFromFunctionRole(selectedRole, userType, ref returnMessage); 00834 if (success) 00835 { 00836 success = selectedRole.RemoveUserType(userType, ref returnMessage); 00837 00838 this.EnableDisableControls(); 00839 } 00840 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult, 00841 returnMessage, 00842 success); 00843 } 00844 } 00845 } 00846 00847 private bool ValidateRemoveUserTypeFromFunctionRole(FunctionRole selectedRole, UserTypeData userType, ref string returnMessage) 00848 { 00849 return RAIS.ApplicationLogicLayer.UserManagement.ValidateRemoveUserTypeFromFunctionRole(selectedRole, userType, ref returnMessage); 00850 } 00851 #endregion 00852 #region Private helper properties 00853 00856 private FunctionRole SelectedRole 00857 { 00858 get 00859 { 00860 FunctionRoles functionRoles = (FunctionRoles)this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG]; 00861 if (functionRoles != null && functionRoles.ContainsKey(this.DDLfmrolename.SelectedValue)) 00862 return functionRoles[this.DDLfmrolename.SelectedValue]; 00863 else 00864 return null; 00865 } 00866 } 00870 private FunctionRole.Category SelectedCategory 00871 { 00872 get 00873 { 00874 FunctionRoleCategories categories = (FunctionRoleCategories)this.Session[UI.Common.Constants.FUNCTION_ROLE_CATEGORIES_TAG]; 00875 if (categories != null && categories.ContainsKey(this.DDLfmcategories.SelectedValue)) 00876 return categories[this.DDLfmcategories.SelectedValue]; 00877 else 00878 return null; 00879 } 00880 } 00884 private FunctionRole.Subcategory SelectedSubcategory 00885 { 00886 get 00887 { 00888 FunctionRoleSubcategories subcategories = (FunctionRoleSubcategories)this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLE_SUBCATEGORIES_TAG]; 00889 if (subcategories != null && subcategories.ContainsKey(this.DDLfmsubcategories.SelectedValue)) 00890 return subcategories[this.DDLfmsubcategories.SelectedValue]; 00891 else 00892 return null; 00893 } 00894 } 00898 private Mask SelectedMask 00899 { 00900 get 00901 { 00902 Masks masks = (Masks)this.Session[RAIS.UI.Common.Constants.MASKS_TAG]; 00903 if (masks != null && masks.ContainsKey(this.DDLfmmask.SelectedValue)) 00904 return masks[this.DDLfmmask.SelectedValue]; 00905 else 00906 return null; 00907 } 00908 } 00912 private FunctionRoleAttribute SelectedRoleAttribute 00913 { 00914 get 00915 { 00916 FunctionRole selectedRole = this.SelectedRole; 00917 if (selectedRole != null && selectedRole.Attributes.ContainsKey(this.LBfm.SelectedValue)) 00918 return selectedRole.Attributes[this.LBfm.SelectedValue]; 00919 else 00920 return null; 00921 } 00922 } 00926 bool EditMode 00927 { 00928 get 00929 { 00930 if (this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLE_EDIT_MODE_TAG] != null) 00931 return (bool)this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLE_EDIT_MODE_TAG]; 00932 else 00933 return false; 00934 } 00935 set 00936 { 00937 this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLE_EDIT_MODE_TAG] = value; 00938 this.EnableDisableControls(); 00939 } 00940 } 00944 bool Modified 00945 { 00946 get 00947 { 00948 if (this.SelectedRole != null) 00949 return this.SelectedRole.Modified; 00950 else 00951 return false; 00952 } 00953 set 00954 { 00955 if (!value) 00956 { 00957 this.SelectedRole.Modified = false; 00958 this.Session[RAIS.UI.Common.Constants.DATA_ROLES_TAG] = null; 00959 this.EnableDisableControls(); 00960 } 00961 } 00962 } 00966 protected UserData CurrentUser 00967 { 00968 get { return (UserData)this.Session[UI.Common.Constants.CURRENT_USER_TAG]; } 00969 } 00970 #endregion 00971 } 00972 }